package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFillFlag;
import com.sky.dto.EmployeeDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 新增员工
     *
     * @param emp
     */
    @AutoFillFlag(OperationType.INSERT)
    public void insertEmp(Employee emp);

    /**
     * 分页查询员工
     * @param name
     * @return
     */
    public Page<Employee> getEmps(String name);

    /**
     * 改变员工账号状态
     * @param status
     * @param id
     */
    @Update("update employee set status = #{status} where id=#{id}")
    public void changeStatus(Integer status, Long id);

    /**
     * 根据id查询员工信息
     * @param id
     * @return
     */
    @Select("select * from employee where id = #{id}")
    public Employee queryById(Long id);

    /**
     * 修改员工信息
     * @param emp
     */
    @AutoFillFlag(OperationType.UPDATE)
    public void changeEmp(Employee emp);

}
